package com.feng.zhihao.apigeteway.controller.interfaces;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.feng.zhihao.apigeteway.controller.BaseController;
import com.feng.zhihao.apigeteway.dao.interfaces.InterfaceFieldInfoDao;
import com.feng.zhihao.apigeteway.entity.InterfaceFieldInfo;
import com.feng.zhihao.apigeteway.entity.InterfaceInfo;
import com.feng.zhihao.apigeteway.page.RestData;
import com.feng.zhihao.apigeteway.util.BeanUtil;
import com.xiaoleilu.hutool.log.LogFactory;

@Controller
@RequestMapping("/interfaceField")
public class InterfaceFieldInfoController extends BaseController{
	com.xiaoleilu.hutool.log.Log logger = LogFactory.get();
	
	@Autowired
	InterfaceFieldInfoDao interfaceFieldInfoDao;
	
	@RequestMapping("getInterfaceField.do")
	@ResponseBody
	public RestData getInterfaceField(@RequestParam(name="interfaceId",required=false)String interfaceId,@RequestParam(name="interfaceFieldId",required=false)String interfaceFieldId,Model model){
		Collection<InterfaceFieldInfo> interfaceInfoItem = null;
		if(interfaceId != null){
			interfaceInfoItem = interfaceFieldInfoDao.findByInterfaceInfo(new InterfaceInfo(interfaceId));	
			BeanUtil.cleanArray(interfaceInfoItem,2);
		}else{
			interfaceInfoItem = interfaceFieldInfoDao.getOne(interfaceFieldId).getInterfaceFieldInfos();
			BeanUtil.cleanArray(interfaceInfoItem,2);
		}
		return new RestData(interfaceInfoItem);
	}

}
